//InnerAudioContext实例
//const app = getApp()

 
Component({
/**
   * 组件的属性列表
   */
  properties: {
    tips: {
      type: Array,
      value: [],
      observer: function (n) {
        if (n.length) {
          n.forEach(item => {
            if (item.type == 'warn') {
              item.w = item.tip_content.length * 40;
            } else {
              item.w = item.btn.length * 120;
            }

          })
          this.setData({
            tipsArr: n
          })
        }
      }
    },
    callbackFn: {
      type: Function,
      value: () => {}
    },
    tip0: {
      type: String,
      value: '',
      observer: function (n) {
        if (n.length) {
          this.setData({
            tip0: n
          })
        }
      }
    },
    tip1: {
      type: String,
      value: '',
      observer: function (n) {
        if (n.length) {
          this.setData({
            tip1: n
          })
        }
      }
    },
    tip2: {
      type: String,
      value: '',
      observer: function (n) {
        if (n.length) {
          this.setData({
            tip2: n
          })
        }
      }
    },
  },
  /**
   * 组件的初始数据
   */
  data: {
    qiu1:0,
    qiu2:0,
    qiu3:0,
    qiu4:0,
    qiu5:0,
    qiu6:0,
    qiu7:0,
    ok1:'268,',
    answer:0,
    qiu:'',
    num:0,
    btn1:'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/images/d24b23809e200db5c90d886ea92270d3.png',
    btn2:'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/images/d24b23809e200db5c90d886ea92270d3.png',
    btn3:'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/images/d24b23809e200db5c90d886ea92270d3.png',
    btn4:'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/images/d24b23809e200db5c90d886ea92270d3.png',
    btn5:'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/images/d24b23809e200db5c90d886ea92270d3.png',
    btn6:'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/images/d24b23809e200db5c90d886ea92270d3.png',
    btn7:'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/images/d24b23809e200db5c90d886ea92270d3.png',
    btn8:'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/images/d24b23809e200db5c90d886ea92270d3.png',
    btn9:'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/images/d24b23809e200db5c90d886ea92270d3.png',
    btn:'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/images/4c7920edba7bfafbd342b39d5889a00c.png',
    btnno:'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/images/d24b23809e200db5c90d886ea92270d3.png',
  },
  /**
  * 页面加载完成执行
  */
 lifetimes:{
  ready(){
    var that =this;
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        // 屏幕宽度、高度
        console.log('height=' + res.windowHeight);
        console.log('width=' + res.windowWidth);
        // 高度,宽度 单位为px
        that.setData({
          windowHeight:  res.windowHeight,
          windowWidth:  res.windowWidth,
          //buttonTop1:buttonTop1,//这里定义按钮的初始位置
          //buttonLeft:res.windowWidth*0.70,//这里定义按钮的初始位置
        })
      }
    })
    

  },
  attached: function() {
    // 在组件实例进入页面节点树时执行
  },
  detached: function() {
    // 在组件实例被从页面节点树移除时执行
  },
},
 //组件所在页面的生命周期
 pageLifetimes: {
  show: function() {
    // 页面被展示
  },
  hide: function() {
    // 页面被隐藏
  },
  resize: function(size) {
    // 页面尺寸变化
  }
},
   /**
   * 组件的方法列表
   */
  methods: {

  //逆时针播放按钮事件
  playQiu : function(e){
    var that = this;
    let qiu = e.currentTarget.dataset.qiu;
    let btn = 'btn'+qiu;
    let ok1 = that.data.ok1;
    let btnyes = this.data.btn;
    let btnno = this.data.btnno;
    var answer = that.data.answer;
    let ok = that.data.qiu+qiu;
    let i = that.data.num+1;
    console.log('num='+i)
    if(i%3 ==0){
      ok = ok+',';
      console.log('i='+i+' ok='+ok)
      var index1 = ok1.indexOf(ok);

      console.log('index1=='+index1)
      if(ok1.indexOf(ok)>=0){
        
        wx.showToast({
          title: '答案正确',
          icon: 'success',     //默认值是success,就算没有icon这个值，就算有其他值最终也显示success
          duration: 2000,      //停留时间
        })
        
      }
      else{
        wx.showToast({
          title: '答案错误',
          icon: 'error',     //默认值是success,就算没有icon这个值，就算有其他值最终也显示success
          duration: 2000,      //停留时间
        })
        ok = '';
        i=0;
        answer=0;
        btnyes = btnno;
        that.setData({
          'qiu':ok,
          'answer':answer,
          'num':i,
          btn1: btnno,
          btn2: btnno,
          btn3: btnno,
          btn4: btnno,
          btn5: btnno,
          btn6: btnno,
          btn7: btnno,
          btn8: btnno,
          btn9: btnno,
        });
      }
    }
    console.log('qiu='+qiu+' answer='+answer+' btn='+btn)

    that.setData({
      'qiu':ok,
      'answer':answer,
      'num':i,
      [btn]: btnyes,
    });
    
  },
 /*
     * 内部私有方法建议以下划线开头
     * triggerEvent 用于触发事件
     */
    _okEvent(){
      //触发取消回调
      var that = this;
      console.log('触发取消回调')
      var isOk = 0;
      if(that.data.answer==3){
        isOk = 1;
      }
      return isOk;
      //this.triggerEvent("cancelEvent")
    },
    _confirmEvent(){
      //触发成功回调
      this.triggerEvent("confirmEvent");
    },
  //顺时暂停按钮事件
  playForward : function(){
    let gnum = this.data.go_num;
    this.doorChange(gnum);

    // that.setData({
    //   [qiu]:qiu,
    // });
  },
 
  //停止按钮事件
  playRight : function(e){
    var that = this;

    let rnum = this.data.right_num;
    let direction = e.currentTarget.dataset.direction;
    var pan_rotate = that.data.pan_rotate+45;
    that.setData({
      pan_rotate:pan_rotate,
    });
    setTimeout(function () {
      //要延时执行的代码
      that.doorChange(direction);
     }, 300) //延迟时间 这里是1秒

  },
 
  
 

  
  }
})